package com.tc.utils;

import lombok.Data;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Data
@Component
public class Json {

    public Map<String,String> parseStr(String response){
        System.out.println(response);
        //先把秘钥和openid分割
        String[] arr1=response.split("\"");
        for (String s : arr1) {
            System.out.println(s);
        }
        //把字符储存到数组中
        String[] arr2={arr1[1],arr1[3],arr1[5],arr1[7]};
        //储存到Map集合中
        Map<String,String> map=new HashMap<>();
        //添加sessionKey
        map.put(arr2[0],arr2[1]);
        //添加openid
        map.put(arr2[2],arr2[3]);
        return map;
    }
}
